<div class="prompt">
	<span class="prompt-text"></span>
</div>
<header class="header">
	<div class="h-top">
		<div class="k-row">
			<p class="declare fl">好的生活，没那么贵</p>
			<div id="main-menu-user">
				<div class="dropdown user fr">
					<a href="#">关于我们</a>
				</div>
				<div class="spacer"></div>
				<div class="dropdown user fr login item">
					<a class="dropdown-toggle user" data-toggle="dropdown" href="{:U('user/center/index')}">					
					<span class="user-nicename"></span><b class="caret"></b><i class="fa fa-angle-down"></i></a>
					<div class="dropdown-menu">
						<a href="{:U('user/center/index')}">个人中心</a>
						<div class="spacer2"></div>
						<a href="{:U('user/profile/myorder')}">订单管理</a>
						<div class="spacer2"></div>
						<a href="{:U('user/index/logout')}">退出</a>
					</div>					   					
				</div>
				<div class="dropdown user fr offline">
					<a href="{:leuu('user/login/index')}">登陆</a>
					<a href="{:leuu('user/register/index')}" class="register">注册</a>
				</div>								
			</div>
			
		</div>
	</div>
	<div class="header-main">
		<div class="k-row">
			<div class="logo fl">
				<a href="__ROOT__/"><img src="__TMPL__Public/assets/images/newLogo.png" alt="" /></a>
			</div>
			<div class="search-bar fl">
				<form method="post" class="form-inline" action="{:U('Goods/search/index')}" >
					<input type="text" class="search-input pull-left" placeholder="Search" name="keyword" value="{:I('get.keyword')}"/>
					<button class="search-btn"><i class="fa fa-search"></i></button>
				</form>
			</div>
			<div id="header_cart_list" class="c-fixed">
				<div class="micart">
					<div class="cart-btn les" onclick="window.location.href='{:U('Goods/Cart/cart')}'"><p class="my-cart"><i class="fa fa-shopping-cart "></i>我的购物车 <span class="shopping-num"><em id="cart_quantity"></em><b></b></span></p></div>
					<!--加入购物车-->
					<div class="j-mini-cart ris">
						
					</div>
				</div>
			</div>		   		   
		</div>
	</div>
	<div class="header-nav fixed" id="main-menu">
		<div class="k-row">
       	<?php
			$effected_id="main-menu";
		  	$filetpl="<a href='\$href' target='\$target'>\$label</a>";
		  	$foldertpl="<a href='\$href' target='\$target' class='dropdown-toggle' data-toggle='dropdown'>\$label <b class='caret'></b></a>";
		  	$ul_class="nav-sub" ;
		  	$li_class="item" ;
		  	$style="tab-nav";
		  	$showlevel=6;
		  	$dropdown='';
		  	echo sp_get_menu("main",$effected_id,$filetpl,$foldertpl,$ul_class,$li_class,$style,$showlevel,$dropdown);
		?>
		
		</div>
    </div>
	
</header>

	<script>

$(function(){
    var active_li = '{$active}';
    if(active_li){
        $('li').remove('curr-res');
        $('#'+active_li).addClass('curr-res');
    }
   	
    var uname= getCookie('uname');
    if(uname == ''){
    	$('.islogin').remove();
    	$('.nologin').show();
    }else{
    	$('.nologin').remove();
    	$('.islogin').show();
    	$('.userinfo').html(decodeURIComponent(uname));
    }
   
	get_cart_num();
})

 

function get_cart_num(){
	  var cart_cn = getCookie('cnum');
	  if(!cart_cn){
		cart_cn = 0;
	  }else{
		$.ajax({
			type : "GET",
			url:"{:U('Goods/Cart/header_cart_list')}",//+tab,
			success: function(data){								 
				cart_cn = getCookie('cnum');	
				
				$('#cart_quantity').html(cart_cn);
			}
		});	
	  }
	  $('#cart_quantity').html(cart_cn);
}
/**
* 鼠标移动端到头部购物车上面 就ajax 加载
*/
// 鼠标是否移动到了上方
var header_cart_list_over = 0;

$("#header_cart_list > .micart > .les").hover(function(){
		
       if(header_cart_list_over == 1){		
		return false;
	   }
				
        header_cart_list_over = 1; 
		
		$.ajax({
			type : "GET",
			url:"{:U('Goods/Cart/header_cart_list')}",//+tab,
			success: function(data){				
			 	$("#header_cart_list > .micart > .ris").html(data);	
			 	get_cart_num();
			}
		});			
}).mouseout(function(){
	
	 /*(typeof(t) == "undefined") || clearTimeout(t); 	 
	 t = setTimeout(function () { 
			header_cart_list_over = 0; /// 标识鼠标已经离开
			
		}, 1000);	*/	
});
</script>
<script type="text/javascript">
	//删除购物车商品
	function delCart(goods_id,path,_this){
		if(goods_id !== ''){
			$.ajax({
				type : "post",
				url:"{:U('Goods/Cart/ajaxDelTopCart')}",//+tab,
				data:{goods_id:goods_id,spec_path:path},
				success: function(data){								 
					//$(_this).parent().remove();
					//var carnum = $('#cart_quantity').html();
					//carnum--;
					//$('#cart_quantity').html(carnum);
					$.ajax({
						type : "GET",
						url:"{:U('Goods/Cart/header_cart_list')}",//+tab,
						success: function(data){				
						$("#header_cart_list > .micart > .ris").html(data);	
						get_cart_num();
					}
					});
				}
			});
		}
	}
</script>
<script type="text/javascript">
	$(document).ready(function(e) {			
	t = $('.fixed').offset().top;
	
	$(window).scroll(function(e){
	s = $(document).scrollTop();	
		if(s > 180){
			$('.fixed').css('position','fixed');							
		}else{
			$('.fixed').css('position','');
		}
	})				
	});
	
</script>
<script type="text/javascript">
	$(document).ready(function(e) {			
	t = $('.c-fixed').offset().top;
	
	$(window).scroll(function(e){
		s = $(document).scrollTop();	
		if(s > 180){
			$('.c-fixed').css('position','fixed');						
			$('.c-fixed').addClass('my-cart');						
		}else{
			$('.c-fixed').css('position','');
			$('.c-fixed').removeClass('my-cart');
		}
	})
	
	});

</script>
